<?php
/**
 * Created by PhpStorm.
 * User: dungnt13
 * Date: 12/9/14
 * Time: 3:33 PM
 */

namespace App\Services;

use Config, View, Sentry, Mail, EmailQueue, Lang;

class Mailer
{
    public function sendMail($data = array())
    {
//        if(Config::get('mail.sentmail')){
//
//        }
        switch ($data['type']) {
            case 'forgot-password':
                $data['short_teaser'] = Lang::get('email.page.title') . ' - ' . Lang::get('email.activity.forgot');
                break;
            case 'register-activate':
                $data['short_teaser'] = Lang::get('email.page.title') . ' - ' . Lang::get('email.activity.activate');
                break;
            default:
                break;
        }

        if (isset($data['saveToDB']) && $data['saveToDB'] == true) {

        } else {
            Mail::send('emails.' . $data['type'], $data, function ($m) use ($data) {
                    $m->to($data['user']->email, $data['user']->username);
                    $m->subject($data['short_teaser']);
                }
            );
        }
    }
} 